@extends('admin/layout')

@section('content')
    <script>
        function del()
        {
            if(confirm("确定要删除吗？"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        function display() {
            document.getElementById('display').style.display = ""
        }
    </script>
    <div class="content-wrapper" style="overflow: auto;">
        <!-- Content Header (Page header) -->
        <section>

            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li><a href="#">会员管理</a></li>
                <li class="active"> 会员列表</li>
            </ol>
            <div class="input-group margin">
                <div style="float: left">
                    <form action="{{ url('admin/users') }}" method="post">
                        {{ csrf_field() }}
                        <div style="float: left">
                            <select style="width: 150px" id="sel" onchange="select()" name="searchtype" class="form-control">
                                @foreach($list['searchtype'] as $value)
                                    <option value="{{ $value['id'] }}">{{ $value['searchtype'] }}</option>
                                @endforeach
                            </select>
                        </div>
                        <script>
                            function select() {
                                var val = $('#sel option:selected').val();
                                if(val == 2 || val == 3) {
                                    $('#form').html('<input style="width: 200px" id="data" name="param" type="text" class="form-control" onClick="laydate({istime: true, format: \'YYYY-MM-DD\'})">');
                                }
                                else{
                                    $('#form').html('<input style="width: 200px" id="data" name="param" type="text" class="form-control">');
                                }
                            }
//                       </script>
                        <div style="float: left" id="form">
                            <input style="width: 200px" name="param" type="text" class="form-control">
                        </div>
                        {{--<input style="width: 200px"  name="param" type="text" class="form-control" onClick="laydate({istime: true, format: 'YYYY-MM-DD'})">--}}
                         <div style="float: left">
                             <input type="submit" class="btn btn-info btn-flat" value="Go!">
                         </div>
                    </form>
                </div>
                {{--<div style="float: left;margin-left: 50px;">--}}
                    {{--@if(!empty($param))--}}
                        {{--<a href="{{ url('admin/out/'.$param.'/'.$search) }}" class="btn btn-warning btn-sm" >导出名单</a>--}}
                        {{--<input type="button" onclick="display()" class="btn btn-warning btn-sm" value="添加会员">--}}
                    {{--@endif--}}
                {{--</div>--}}

            </div>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12" style="width: 100%;">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">内容</h3>
                        </div>
                        <span id="msg" style="display: none">
                            @if (count($errors) > 0)
                                @foreach ($errors->all() as $error)
                                    <div style="width: 100%;">
                                        <span style="color: red;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ $error }}</span>
                                    </div>
                                @endforeach
                            @else
                                <div style="width: 100%;">
                                    <span style="color: green;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ Session::get('msg') }}</span>
                                </div>
                            @endif
                        </span>
                        <script type="text/javascript">
                            var _msg = $('#msg div span').text();
                            console.log(_msg);
                            if(_msg != ''){
                                layer.msg(_msg);
                            }
                        </script>
                        <div class="box-body" style="overflow: auto;">
                            <table class="table table-striped table-hover text-center">
                                <tr>
                                    @foreach($list['searchtype'] as $value)
                                        <th style="width: 75px; text-align:center;min-width: 75px">{{ $value['searchtype'] }}</th>
                                    @endforeach
                                    <th style="width: 190px; text-align: center;min-width: 200px;">操作</th>
                                </tr>
                                @foreach($list['data'] as $value)
                                    <tr>
                                        <td>{{ $value['id'] }}</td>
                                        <td>{{ $value['create_time']}}</td>
                                        <td>{{ $value['update_time']}}</td>
                                        <td>{{ $value['rank']}}</td>
                                        <td>{{ $value['name']}}</td>
                                        <td>{{ $value['integral'] }}</td>
                                        <td>{{ $value['phone']}}</td>
                                        <td>{{ $value['email']}}</td>
                                        {{--<td>{{ $value['sex'] }}</td>--}}
                                        <td>
                                            {{ $value['sex'] }}
                                        </td>
                                        <td>{{ $value['birth']}}</td>
                                        <td>{{ $value['car_num']}}</td>
                                        <td>{{ $value['user_num']}}</td>
                                        {{--<td>{{ $value['mid']}}</td>--}}
                                        <td>
                                            {{ App\Manage::find($value['mid'])['username'] }}
                                        </td>
                                        <td>{{ $value['u_batch']}}</td>
                                        <td>
                                            @if($value['status'] ==1)已启用
                                            @else未启用
                                            @endif
                                        </td>
                                        <td>
                                            {{--<a class="btn btn-success btn-xs"   href="{{ url('admin/users/CollectionList/'.$value['id']) }}">收藏列表<a>--}}
                                            <a class="btn btn-success btn-xs"   href="{{ url('admin/users/integralList/'.$value['id']) }}">积分管理<a>
                                            <a class="btn btn-success btn-xs"  href="{{ url('admin/users/setStatus/'.$value['id'].'/1' )}}" >启用<a>
                                            <a class="btn btn-warning btn-xs"  href="{{ url('admin/users/setStatus/'.$value['id'].'/0') }}" >禁用<a>
                                                    <a class="btn btn-info btn-xs"  href="{{ url('admin/users/getUser/'.$value['id']) }}" >修改<a>
                                        </td>
                                    </tr>

                                @endforeach
                                <tr><td></td></tr>
                                <tr id="display" style="display: none;">
                                    <td colspan="3">会员名称:<br /><input type="text" id="user_name" name="user_name" value=""></td>
                                    <td colspan="3">车牌号:<br /><input type="text" id="car_num" name="car_num" value=""></td>
                                    <td colspan="3">手机号:<br /><input type="text" id="phone" name="phone" value=""></td>
                                    <td colspan="2">积分:<br /><input type="text" id="integ" name="integ" value="" size="15px"></td>
                                    <td colspan="4">详细地址:<br /><input type="text" id="address" name="address" value="" size="50px"></td>
                                    <input type="hidden" id="batch" value="{{ $param }}">
                                    <td colspan="1"><a class="btn btn-success btn-sm" onclick="user()">添加<a></td>
                                </tr>
                            </table>
                        </div>
                        <div calss="pages">
                            <div style="margin: auto; width: 500px;">{{ $man->links() }}</div>
                        </div>
                        <!-- /.box -->
                    </div>

                    <!-- /.row -->
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <script type="text/javascript" src="{{ asset('client/js/laydate.js') }}"></script>
    <!-- /.content-wrapper -->
@stop